<%--
  Created by IntelliJ IDEA.
  User: littleken
  Date: 2020/1/3
  Time: 9:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<!--loginPage-->
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>绿地中央广场综合物业办公系统 - 登录...</title>
    <meta name="keywords" content="绿地中央广场综合物业办公系统">
    <meta name="description" content="绿地中央广场综合物业办公系统">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min.css" rel="stylesheet">
    <link href="css/login.min.css" rel="stylesheet">

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script src="js/jquery.min.js"></script>

</head>
<body class="signin">
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-6">
            <div class="signin-info">
                <div class="logopanel m-b">
                    <h1>[ 广州尚学堂 ]</h1>
                </div>
                <div class="m-b"></div>
                <h4>欢迎使用 <strong>绿地中央广场综合物业办公系统</strong></h4>
                <ul class="m-b">
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势一</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势二</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势三</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势四</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 优势五</li>
                </ul>
                <strong>还没有账号？ <a href="#">立即注册&raquo;</a></strong>
            </div>
        </div>
        <div class="col-sm-6">
            <%--<form method="post" action="#">--%>
                <h3 class="m-t-md">绿地中央广场综合物业办公系统 </h3>
                <div class="form-group has-error">
                    <label id="loginMessage" class="control-label" >欢迎使用本系统！</label>
                </div>
                <input name="username" id="username" type="text" class="form-control uname" placeholder="用户名"/>
                <input name="password" id="password" type="password" class="form-control pword m-b" width="50%" placeholder="密码"/>
                <input name="code" id="code" type="text" class="form-control  code  m-b" placeholder="验证码" />
                <span>
                    	<img  id="codeImage" alt="" src="image.jsp">
                    </span>
                <a id="flushButton">看不清？点击图片更换呗</a>
                <input id="loginButton" type="submit" class="btn btn-success btn-block" value="登录" >
                <a href="#">忘记密码了？</a>
            <%--</form>--%>

        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">
            &copy; 2020
        </div>
    </div>
</div>
<script>
    // ajax
    $(function () {
        function flush(){//刷新验证码
            $("#codeImage").attr("src","image.jsp?time="+new Date())//刷新验证码图片
        }

        $("#codeImage").click(flush)
        $("#flushButton").click(flush)

        $("#loginButton").click(function () {
            var userName = $("#username").val();
            var passWord = $("#password").val();
            var code = $("#code").val();
            //var loginMessage = $("#loginMessage").html();
            //console.log(userName+passWord+code+loginMessage)
            if (userName.length==0){
                $("#loginMessage").html("用户名不能为空")
                //console.log("user")
            } else if (passWord.length == 0) {
                $("#loginMessage").html("密码不能为空")
                // console.log("pwd")
            }else if (code.length == 0) {
                $("#loginMessage").html("验证码不能为空")
                // console.log("code")
            }else {
                $.ajax({
                    url:"login",
                    type:"post",
                    data:{"username":userName,"password":passWord,"code":code},
                    dataType:"json",
                    success:function (data) {
                        console.log(data.ret)
                        if (data.ret){//成功登录，跳转
                            console.log(data.msg)
                            window.location.href="index.jsp";
                        } else{//登录失败请求
                            console.log("ajax>success")
                            $("#loginMessage").html(data.msg)
                            $("#codeImage").attr("src","image.jsp?time="+new Date())//刷新验证码图片
                        }


                    },
                    error:function (data) {
                        console.log("ajax>fail")
                    }
                })
            }
        });
    })
</script>
</body>
</html>


</body>
</html>
